﻿/*
 ***************************************************************************
 * Microsoft Visual C# .NET
 * 名称：       Shpm.App.Input.Dao.HealthAssign
 * 类型：       DAO
 * 功能说明：   主管医生职责维护
 * 作者：       谈震鸣
 * 创建日期：   2007/09/10
 * 修改日期     修改者      修改内容
 * 
 * 
 * ---
 ***************************************************************************
*/
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections;
using Shpm.System.Db;
using Shpm.App.Commons.Db.Beans.Master;
using Shpm.App.Input.Bean;
namespace Shpm.App.Input.Dao
{
    public class HealthAssignDao : ShpmBaseDao
    {
        public const string FIND_BY_EMPLOYEE = "HealthAssignSrh.FindByEmployee";
        public const string FIND_BY_MENBER = "HealthAssignSrh.FindByMenber";
        public const string FIND_BY_MENBERHAVE = "HealthAssignSrh.FindByMenberHave";
        public const string INSERT_MEMBERDOCTOR = "HealthAssignSrh.InsertMemberDoctor";
        public const string UPDATE_DOCTOR = "HealthAssignSrh.UpdateDoctor";
        public const string UPDATE_MENBER = "HealthAssignSrh.UpdateMenber";
        public const string LIST_MENBER = "HealthAssignSrh.ListMenberHave";
        public HealthAssignDao()
        {
        }
        public IList ListMenber(HealthAssignBean paramBean)
        {
            return base.QueryForList(LIST_MENBER, paramBean);
        }
        //读取医生列表
        public IList FindByEmployee(MstEmployeeBean paramBean)
        {
            return base.QueryForList(FIND_BY_EMPLOYEE, paramBean);
        }
        //读取会员列表
        public IList FindByMenber(HealthAssignBean paramBean)
        {
            return base.QueryForList(FIND_BY_MENBER, paramBean);
        }

        //读取已有会员列表
        public IList FindByMenberHave(HealthAssignBean paramBean)
        {
            return base.QueryForList(FIND_BY_MENBERHAVE, paramBean);
        }
        //插入新记录

        public Object InsertMemberDoctor(HealthAssignBean paramBean)
        {
            return base.Insert(INSERT_MEMBERDOCTOR, paramBean);
        }
        //更新医生记录

        public int UpdateDoctor(HealthAssignBean paramBean)
        {
            return base.Update(UPDATE_DOCTOR, paramBean);
        }
        //更新会员记录

        public int UpdateMenber(HealthAssignBean paramBean)
        {
            return base.Update(UPDATE_MENBER, paramBean);
        }

        public int InsertMemberDoctorLst(IList datalist, string str,string strUserId)
        {
            try
            {
                HealthAssignBean DoctorDataBean=new HealthAssignBean ();
                DoctorDataBean.DoctorId = str;
                DoctorDataBean.UserId = strUserId;
                base.BeginTransaction();
                this.UpdateDoctor(DoctorDataBean);
                foreach (HealthAssignBean dataBean in datalist)
                {
                    this.UpdateMenber(dataBean);
                    this.InsertMemberDoctor(dataBean);
                }

                base.CommitTransaction();

                return datalist.Count;
            }
            catch (DataAccessException e)
            {
                Console.WriteLine("********** Exec  sql error! **********");
                Console.WriteLine(e.InnerException);
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
                base.RollBackTransaction();
                throw e;
            }
            finally
            {

            }
        }
    }
}